<?
$src=$_GET["image"];
$e=explode("|",$src);
$src			=$e[0];
/*
if(count($e)==3 && $e[1]>0 && $e[2]>0)
{
	$src			=$e[0];
	$width			= $e[1];
	$height			= $e[2];
}
else{
	$src			=$e[0];
	$size = getimagesize($src);
	$width			= $size[0];
	$height			= $size[1];
}
$owidth			= $width;
$oheight		= $height;
*/
$maxWidth		= (isset($_GET['width'])) ? (int) $_GET['width'] : 0;
$maxHeight		= (isset($_GET['height'])) ? (int) $_GET['height'] : 0;
/*
if (!$maxWidth && $maxHeight)
{
	$maxWidth	= 99999999999999;
}
elseif ($maxWidth && !$maxHeight)
{
	$maxHeight	= 99999999999999;
}
elseif ( !$maxWidth && !$maxHeight)
{
	$maxWidth	= $width;
	$maxHeight	= $height;
}
$offsetX	= 0;
$offsetY	= 0;

if (isset($_GET['cropratio']))
{
	$cropRatio		= explode(':', (string) $_GET['cropratio']);
	$cropPosition	= explode(':', (string) $_GET['croppos']);
	if (count($cropRatio) == 2)
	{
		$ratioComputed		= $width / $height;
		$cropRatioComputed	= (float) $cropRatio[0] / (float) $cropRatio[1];
		
		if ($ratioComputed < $cropRatioComputed)
		{ // Image is too tall so we will crop the top and bottom
			$origHeight	= $height;
			$height		= $width / $cropRatioComputed;
			if($cropPosition[1]=="c") 		$offsetY	= -($origHeight - $height) / 2;
			elseif($cropPosition[1]=="b") 	$offsetY	= -($origHeight - $height);
			else							$offsetY	= 0;
		}
		else if ($ratioComputed > $cropRatioComputed)
		{ // Image is too wide so we will crop off the left and right sides
			$origWidth	= $width;
			$width		= $height * $cropRatioComputed;
			if($cropPosition[0]=="c") 		$offsetX	= -($origWidth - $width) / 2;
			elseif($cropPosition[0]=="r") 	$offsetX	= -($origWidth - $width);
			else							$offsetX	= 0;
		}
	}
}

// Setting up the ratios needed for resizing. We will compare these below to determine how to
// resize the image (based on height or based on width)
$xRatio		= $maxWidth / $width;
$yRatio		= $maxHeight / $height;

if ($xRatio * $height < $maxHeight)
{ // Resize the image based on width
	$tnHeight	= ceil($xRatio * $height);
	$tnWidth	= $maxWidth;
}
else // Resize the image based on height
{
	$tnWidth	= ceil($yRatio * $width);
 	$tnHeight	= $maxHeight;
}
if($oheight/$owidth * ($tnWidth/$tnHeight)<=1)
{
	$s="height:".$tnHeight."px";
}
else
{
	
	$s="width:".$tnWidth."px";
}

echo "<div style='float: left;overflow: hidden;position: relative;width:{$tnWidth}px;height:{$tnHeight}px;margin-right:5px;'>
<img src='$src' style='position: absolute;top:{$offsetY}px;left:{$offsetX}px;$s' id='$id' class='$class' >
</div>";*/
$id=$_GET["id"];
$class=$_GET["class"];
echo '<div style="background:url(\''.$src.'\');float:left;background-size:cover; width:'.$maxWidth.'px;height:'.$maxHeight.'px;" id="'.$id.'"></div>';
?>